#!/usr/bin/env ruby
#
#  Created by Dzema Dmitri on 2006-10-22.
#  Copyright (c) 2006. All rights reserved.
class Token
  attr_reader :error,:value
  def initialize(value,line,pos,error=nil)
    @value = value
    @line = line
    @pos = pos
    @type = "Base"
    @error = error
  end
    
  def to_s
    "#{@type} token at <#{@line},#{@pos}>"
  end
  
  def info
    ""
  end
end

class StartToken < Token
  def to_s
    "Start token <#{@line},#{@pos}>"
  end  
  def info
    "Start"
  end
end

class EndFileToken < Token
  def to_s
    "End of file at  <#{@line},#{@pos}>"
  end
end

class IntegerToken < Token
  def to_s
    "Integer [#{@value}] at <#{@line},#{@pos}>"
  end
  def info
    "Integer\t\t#{@value}"
  end
end

class FloatToken < Token
  def to_s
      "Float [#{@value}] at <#{@line},#{@pos}>"
  end
  def info
    "Float\t#{@value}"
  end
end

class IdentifierToken < Token
  def to_s
    "Identifier [#{@value}] at <#{@line},#{@pos}>"
  end
  def info
    "Identifier\t#{@value}"
  end  
end

class KeywordToken < IdentifierToken
  def to_s
    "Identifier (Keyword) [#{@value}] at <#{@line},#{@pos}>"
  end
  def info
    "Keyword\t#{@value}"
  end
end
  
class OperationToken < Token
  def to_s
    "Operation [#{@value}] at <#{@line},#{@pos}>"
  end
  def info
    "Operation\t#{@value}"
  end
end

class DelimeterToken < Token
  def to_s
    "Delimeter [#{@value}] at <#{@line},#{@pos}>"
  end
  def info
    "Delimeter\t#{@value}"
  end
end

class StringToken < Token
  def initialize(value,line,pos,mark,error=nil)
    @value = value
    @line = line
    @pos = pos
    @error = error
    @mark = mark
  end
  def to_s
    "String [#{@value}] at <#{@line},#{@pos}>"
  end
  def info
    "String\t#{@value}"
  end
end

class ErrToken < Token
  def initialize(error)
    @error = error
  end
  def to_s
    "String [#{@value}] at <#{@line},#{@pos}>"
  end
  def info
    "String\t#{@value}"
  end
end

class EndProgramToken < Token
  def to_s
    "EndProgram at <#{@line},#{@pos}>"
  end
  def info
    "__END__\t#{@value}"
  end
end